home *** CD-ROM | disk | FTP | other *** search
/ Aminet 20 / Aminet 20 (1997)(GTI - Schatztruhe)[!][Aug 1997].iso / Aminet / dev / misc / TdDBdevkit.lha / DataBase / Include / libraries / tddbase.i < prev   
Encoding:
Text File  |  1996-07-03  |  5.7 KB  |  160 lines

  1.           IFND      LIBRARIES_TDDBASE_I
  2. LIBRARIES_TDDBASE_I SET 1
  3.  
  4.           IFND      EXEC_TYPES_I
  5.           INCLUDE   'exec/types.i'
  6.           ENDC
  7.           
  8.           IFND      EXEC_SEMAPHORES_I
  9.           INCLUDE   'exec/semaphores.i'
  10.           ENDC
  11.  
  12.           IFND      EXEC_PORTS_I
  13.           INCLUDE   'exec/ports.i'
  14.           ENDC
  15.           
  16.           IFND      DOS_DOS_I
  17.           INCLUDE   'dos/dos.i'
  18.           ENDC
  19.  
  20.           IFND      UTILITY_TAGITEM_I
  21.           INCLUDE   'utility/tagitem.i'
  22.           ENDC
  23.  
  24. ;
  25. ; This structure is the shared part of a database
  26. ;
  27.           STRUCTURE DataBase,LN_SIZE
  28.  
  29.           ;
  30.           ; Here can you find out who and how many programms that are 
  31.           ; using this database at any time.
  32.           ;
  33.           UWORD UseCnt                  ; Number of opened databases
  34.           STRUCT HandleList,MLH_SIZE    ; List with handlers
  35.           STRUCT HandleSem,SS_SIZE      ; Semaphore to protect handlerlist
  36.  
  37.           ULONG DataID                  ; Identifies the contents of DBase
  38.           ULONG FileType                ; Gives fileformat
  39.  
  40.           ULONG Flags                   ; Reserved for future usage
  41.  
  42.           ULONG Nodes                   ; Number of nodes that belongs to this dbase
  43.  
  44.           ; There exists private data below!
  45.  
  46.  
  47. ; This is the only FileType that is suported.
  48. FILID_STATIC EQU    $44423130           ; 'DB10'
  49.  
  50. ; Use this generic DataID if you do not wish to use datarecognizion.
  51. DBID_NOID EQU       0
  52.  
  53. ; These 2 DataID values are only for testing. Other DataID values can only
  54. ; be registerd via betasoft.
  55. DBID_TEST1 EQU      1
  56. DBID_TEST2 EQU      2
  57.  
  58.           ; This is the process-specific parts of each database.
  59.           STRUCTURE DBHandle,0
  60.           STRUCT    Node,MN_SIZE        ; Linkage in handlerlist.
  61.           APTR      DBase               ; Points back to database.
  62.           APTR      Process             ; The process this handle used by
  63.           ULONG     Error               ; Last errorcode
  64.           ;More private data follows!
  65.  
  66.  
  67. ;Error codes
  68. ERR_NOERR    EQU    0         ; Everything went just fine.
  69. ERR_NONNODE  EQU    1         ; You tried to access a non-existing node.
  70. ERR_NOMEM    EQU    2         ; Ran out of memory.
  71. ERR_DOSERR   EQU    3         ; FileIO error.
  72. ERR_NOTDBASE EQU    4         ; Not a database-file.
  73. ERR_NODEBUSY EQU    5         ; Cant get acess to node.
  74.  
  75.  
  76.           ; This structure defines a node in memory/cache
  77.           STRUCTURE DBNode,SS_SIZE
  78.           UWORD dbn_Flags                   ; Flags, see below for bit-defs
  79.           ULONG dbn_NodeNr                  ; This nodes number
  80.           APTR  dbn_DataList;               ; List with all data
  81.           APTR  dbn_LockProc;               ; The process that has a lock on node */
  82.  
  83. ; NodeFlags
  84. NF_Changed   EQU $0001                  ; You have changed contents of this node */
  85. NF_New       EQU $0002                  ; Node has just been created
  86. NF_Locked    EQU $0004                  ; Node has a "soft" lock on it
  87.  
  88. NB_Changed   EQU 0
  89. NB_New       EQU 1
  90. NB_Locked    EQU 2
  91.  
  92. ; Flags for TDDB_GetNode()
  93. MODEF_READ   EQU $0001                  ; Get read acess
  94. MODEF_WRITE  EQU $0002                  ; Get read/write acess to nide
  95. MODEF_NOWAIT EQU $0004                  ; Dont wait for it to become free
  96.  
  97. ;Here comes some defines/macros to be used on field ID's
  98.  
  99. DATATYPES EQU $F0000000       ; These bits are reserved for datatype
  100.  
  101. INT       EQU $80000000       ; 32 bit value
  102. STRING    EQU $40000000       ; NULL terminated string
  103. BINARY    EQU $C0000000       ; Binary data, first ULONG is total size.
  104.  
  105. ; These macros can be used to define correct FieldID values
  106. IntTag    MACRO     ; FieldID
  107.           Dc.L      INT+\1
  108.           ENDM
  109.  
  110. StrTag    MACRO     ; FieldID
  111.           Dc.L      STRING+\1
  112.           ENDM
  113.  
  114. BinTag    MACRO     ; FieldID
  115.           Dc.L      BINARY+\1
  116.           ENDM
  117.  
  118. ; /* These macros can be used to check a FieldID value against a datatype */
  119. ; #define IsControl(v) (CONTROL==(v & DATATYPES))
  120. ; #define IsInt(v)     (INT==(v & DATATYPES))
  121. ; #define IsString(v)  (STRING==(v & DATATYPES))
  122. ; #define IsBinary(v)  (BINARY==(v & DATATYPES))
  123.  
  124.           ; This structure is returned by TDDB_GetDataItem
  125.           STRUCTURE DataStorage,0
  126.           ULONG     ds_ID            ; Identifies the field data belongs to
  127.           LONG      ds_Data          ; Data for IntTag fields
  128.           LABEL     ds_String        ; String for StrTag fields
  129.           LABEL     ds_Binary        ; Data pointer for BinTag fields.
  130.           LABEL     ds_SIZE
  131.  
  132.  
  133. ; This message is allocated by you and then replyed when something happens.
  134.           STRUCTURE UpdateMsg,MN_SIZE
  135.           APTR      um_DBase            ; Points to origin database.
  136.           APTR      um_Proc             ; The process causing this message
  137.           ULONG     um_Type             ; What have happened?
  138.           ULONG     um_NodeNr           ; On wich node did it happen?
  139.           ULONG     um_MoreData         ; Is there more to know?
  140.           LABEL     um_SIZE
  141.  
  142. ; Types of UpdateMsg know today
  143. MSG_NEWNODE    EQU  0         ; Node has been created.
  144. MSG_DELNODE    EQU  1         ; Node has been deleted.
  145. MSG_NODELOCK   EQU  2         ; Node is now to considered locked
  146. MSG_NODEUNLOCK EQU  3         ; Node nolonger is locked
  147. MSG_CHANGED    EQU  4         ; There are new data stored in it
  148. MSG_USER       EQU  5         ; Caused by a call to TDDB_ShowUpdate()
  149. MSG_ABORTED    EQU  6         ; Message has been aborted.
  150. MSG_SWAP       EQU  7         ; Nodes are swaped, MoreData is number of
  151.                               ; number of the other node.
  152.  
  153. ; Tags for TDDB_SeekBase() and TDDB_Find#?()
  154.  
  155. SBT_Dummy     EQU   TAG_USER
  156.  
  157. SBT_StartNode EQU   (SBT_Dummy+1)       ; ti_Data is nodenr to start from
  158.                                         ; instead of 0
  159.  
  160.           ENDC ;LIBRARIES_TDDBASE_I